/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package boundaries;

import business.UserManager;
import entity.User;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

/**
 *
 * @author Alessandro
 */
@Named(value="registrationBean")
@RequestScoped
public class RegistrationBean {
    
    private User user;
    @EJB
    private UserManager um;
    

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    public RegistrationBean() {
        um = new UserManager();
    }

    public User getUser() {
        if(user == null){            
            user=new User();
        }
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
    
    public String register(){
        um.save(user);
        System.out.println(user.getFirstName());
        System.out.println(user.getLastName());
        return "index";
         
    }
    
}
